#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#define ll long long
using namespace std;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	ll n,L,R,Ans=0;
	cin>>n>>L>>R;
	if(R-L>n || L==n || R==n){
		cout<<n-1;
		return 0;
	}
	for(int i=L;i<=R;i++){
		Ans=max(Ans,i%n);
		if(Ans==n-1){
			cout<<Ans;
			return 0;
		}
	}
	cout<<Ans;
	return 0;
}
